import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  Dimensions,
  Image,
  FlatList
} from 'react-native';
import { connect } from 'react-redux';
import { changeShowWeek, changeCurWeek } from '../../actions/courses';

import Header from '../../components/courses/header';
import WeekName from '../../components/courses/weekName';
import Table from '../../components/courses/table';

class CoursesScreen extends Component {
  render() {
    return (
      <View>
        <Header 
          onPress={this.props.changeShowWeek}
          currentWeek={this.props.courses.currentWeek}
          showWeek={this.props.courses.showWeek}
          totalWeeks={this.props.courses.totalWeeks} />
        
        <WeekName 
          firstDay={this.props.courses.firstDay} 
          showWeek={this.props.courses.showWeek} />
        <View>
          <Table />
        </View>
      </View>
    );
  }
}

const mapStateToProps = (state) => {
  return {
    courses: state.courses
  }
}

const mapDispatchToProps = (dispatch) => {
  return {
    changeShowWeek: (num) => {
      dispatch(changeShowWeek(num));
    },
    changeCurWeek: (num) => {
      dispatch(changeCurWeek(num))
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(CoursesScreen);